//
//  SDAccount.swift
//  Seed
//
//  Created by Samuel on 2017/6/7.
//  Copyright © 2017年 RedSoft. All rights reserved.
//

import UIKit

class SDAccount: NSObject, NSCoding {
    var nickname:String?
    var headImgUrl:String?
    var videoToken:String?
    var token:String?
    
    init(dict: [String:AnyObject]) {
        nickname = dict["nickname"] as? String
        headImgUrl = dict["headImgUrl"] as? String
        videoToken = dict["video_token"] as? String
        token = dict["token"] as? String
    }
    
    override var description: String{
        return "nickname:\(nickname ?? "")  headImgUrl:\(headImgUrl ?? "") videoToken:\(videoToken ?? "")  token:\(token ?? "")"
    }
    
    //接档
    required init?(coder aDecoder: NSCoder) {
        self.nickname = aDecoder.decodeObject(forKey: "nickname") as? String
        self.headImgUrl = aDecoder.decodeObject(forKey: "headImgUrl") as? String
        self.videoToken = aDecoder.decodeObject(forKey: "videoToken") as? String
        self.token = aDecoder.decodeObject(forKey: "token") as? String
    }
    //归档
    func encode(with aCoder: NSCoder) {
        aCoder.encode(self.nickname, forKey: "nickname")
        aCoder.encode(self.headImgUrl, forKey: "headImgUrl")
        aCoder.encode(self.videoToken, forKey: "videoToken")
        aCoder.encode(self.token, forKey: "token")
    }
}
